package com.example.lenovo.mywechat.homepage.wechat;


import android.os.Bundle;
import android.app.Fragment;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.lenovo.mywechat.R;

import java.util.ArrayList;
import java.util.List;

public class WechatFragment extends Fragment {


    public WechatFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.wechat_content, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        Session session1 = new Session(R.drawable.wechat_normal, "title_1",
                "briefIntroduction_1", "time_1");
        Session session2 = new Session(R.drawable.wechat_pressed, "title_2",
                "briefIntroduction_2", "time_2");
        Session session3 = new Session(R.drawable.find_normal, "title_3",
                "briefIntroduction_3", "time_3");

        List<Session> sessions = new ArrayList<>();
        sessions.add(session1);
        sessions.add(session2);
        sessions.add(session3);

        SessionAdapter adapter = new SessionAdapter(sessions, this.getActivity());

        RecyclerView content = getActivity().findViewById(R.id.wechat_content_recycler_view);
        content.setLayoutManager(new LinearLayoutManager(getContext()));
        content.setAdapter(adapter);
    }
}
